package sistema.seguimiento.items.spring.httpInvoker;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter;

/**
 * Comprime con GZip los datos serialiazos.
 */
public class GZipHttpInvokerServiceExporter extends HttpInvokerServiceExporter {

  /**
   * @see HttpInvokerServiceExporter#decorateInputStream(HttpServletRequest,
   *      java.io.InputStream)
   */
  protected InputStream decorateInputStream(final HttpServletRequest request,
      final InputStream is) throws IOException {
    return new GZIPInputStream(is);

  }

  /**
   * @see HttpInvokerServiceExporter#decorateOutputStream(HttpServletRequest,
   *      HttpServletResponse, java.io.OutputStream)
   */
  protected OutputStream decorateOutputStream(final HttpServletRequest request,
      final HttpServletResponse response, final OutputStream os)
      throws IOException {
    return new GZIPOutputStream(os);

  }
}
